home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / TSRPARK.ASM < prev    next >
Assembly Source File  |  1988-07-18  |  21KB  |  485 lines

  1.         PAGE 60,120
  2.         TITLE TSRPARK.ASM -- TesSeRact Demo program to park disk drive heads
  3. ;----------------------------------------------------------------------------
  4. SUBTTL  Originally TESSPARK.ASM : TesSeRact Revision Level 1
  5. ;-----------------------------------------------------------------------------
  6. ;   TesSeRact(tm) -- A Library of Routines for Creating Ram-Resident (TSR)
  7. ;                    programs for the IBM PC and compatible Personal
  8. ;                    Computers.
  9. ;
  10. ;The software, documentation and source code are:
  11. ;
  12. ;       Copyright (C) 1986, 1987, 1988 Tesseract Development Team
  13. ;       All Rights Reserved
  14. ;
  15. ;       c/o Chip Rabinowitz
  16. ;       Innovative Data Concepts
  17. ;       2084 Woodlawn Avenue
  18. ;       Glenside, PA 19038
  19. ;       1-215-884-3373
  20. ;
  21. ;-----------------------------------------------------------------------------
  22. ;   This product supports the TesSeRact Standard for Ram-Resident Program
  23. ;   Communication.  For information about TesSeRact, contact the TesSeRact
  24. ;   Development Team at:
  25. ;       Compuserve:    70731,20
  26. ;       MCIMAIL:       315-5415
  27. ;   This MCIMAIL Account has been provided to the TesSeRact Development
  28. ;   Team by Borland International, Inc.  The TesSeRact Development Team
  29. ;   is in no way associated with Borland International, Inc.
  30. ;-----------------------------------------------------------------------------
  31. ;
  32. ; BASED on code originally provided by Jim Mischel
  33. ;
  34. ; ORIGINAL COPYRIGHT NOTICE:
  35. ;
  36. ;;;; AUTOPARK.ASM - program to automatically park the disk drive heads
  37. ;;;; at specified time intervals.
  38. ;;;;
  39. ;;;; Copyright (c) 1988, Jim Mischel
  40. ;;;;
  41. ;;;; This program has been assembled using MASM 5.0.  Changes may be required
  42. ;;;; for use with earlier versions.
  43. ;;;;
  44.  
  45. ;;;;;                 TSRPARK.ASM -  Rick Housh
  46. ;;;;;
  47. ;;;;; TSRPARK.ASM - Modifications to TESSPARK.ASM to allow variable timing
  48. ;;;;; intervals from 1 to 9 minutes for autopark with use of numerical
  49. ;;;;; parameter on command line, to support manual parking with use
  50. ;;;;; of hotkey, with popup when on DOS command line, detection of
  51. ;;;;; park failure on installation, and communication with the resident
  52. ;;;;; program to allow dynamically changing the elapsed time between
  53. ;;;;; automatic parks.  Assembled using MASM 5.1.
  54. ;;;;;
  55. ;;;;; Everything is self-explanatory, except perhaps how to reset the
  56. ;;;;; timer when resident.  Just enter ' TSRPARK # ', where # is any number
  57. ;;;;; of minutes between 1 and 9, and the new value will be inserted in the
  58. ;;;;; resident portion of the program.  A message will confirm the change
  59. ;;;;; and even the MAPMEM display of residents will show the new value.
  60. ;;;;; Entering ' TSRPARK ' with no parameter will yield a confirming message
  61. ;;;;; if TSRPARK is resident, and an instructional message if it has not
  62. ;;;;; yet been installed.  When the hotkey is pressed from the DOS prompt
  63. ;;;;; a message is displayed, in addition to the TESSBEEP sound.  Inside
  64. ;;;;; a program, the sound will occur, but there will be no message.
  65. ;;;;;
  66. ;;;;; I have changed the "mysterious" headparking code somewhat, and tried
  67. ;;;;; to expand the comments to show how it really works.  It's not that
  68. ;;;;; complicated, and does NOT care whether the computer is an AT or not,
  69. ;;;;; contrary to the comments in the original TESSPARK.  I have also found
  70. ;;;;; an undocumented and useful function.  Tch, tch.  TSRCHECKRESIDENT
  71. ;;;;; returns the segment of the resident program in the es register if
  72. ;;;;; it has found the program installed in memory.  The documentation
  73. ;;;;; only mentions a result returned in the ax register.  I found this
  74. ;;;;; very useful, and have implemented in TSRPARK.
  75. ;;;;;
  76. ;;;;; TSRPARK Modifications of TESSPARK, Rick Housh, CIS 72466,212 - 7/18/1988
  77. ;;;;;
  78.  
  79. ;;;;;
  80. ;;;;; To assemble this TesSeRact version:
  81. ;;;;;
  82. ;;;;;       MASM TSRPARK;
  83. ;;;;;       LINK TESS_ASM + TESS_BP + TSRPARK + TESS_END,TSRPARK;
  84. ;;;;;       EXE2BIN TSRPARK.EXE TSRPARK.COM
  85. ;;;;;
  86.  
  87. .model small
  88.  
  89. .code
  90.  
  91. ;
  92. ; Ticks2wait is # of timer ticks to wait between the last disk access
  93. ; and parking the disk.  There are approximately 18.2 ticks per second.
  94. ;
  95. ; Maximum possible ticks2wait is 65536 ticks, very close to 1 hour.
  96. ; Limit with this configuration is 9828 (9 minutes).
  97. ;
  98.  
  99. ticks_min       equ     1092            ;Number of timer ticks in 1 minute
  100. tinkle          equ     1               ;Sound TESSBEEP if set
  101.                                         ;set tinkle to 0
  102.                                         ;for no sound
  103. tick_count      dw      ?               ;Current count
  104. ticks2wait      dw      ?               ;Ticks to wait: 1092 = 1 minute
  105.  
  106. ;
  107. ; The parkit routine attempts to park all hard disks.
  108. ; Returns with carry set if park was unsuccessful.
  109. ;
  110. parkit  proc    near
  111.         mov     si,0080h                ;Hard drive id nos. start at 80h
  112. pk0:    mov     ah,08h                  ;Function gets drive parms.
  113.         mov     dx,si                   ;DX is drive ID No.
  114.         int     13h                     ;Get drive parms, dl = No. of drives
  115.         jc      pkdone                  ;Error if carry, jump out
  116.         xor     dh,dh                   ;Don't need max head-side number
  117.         mov     di,dx                   ;Save drive count from dl to di
  118.         cmp     di,01h                  ;Is there at least one?
  119.         jb      pkdone                  ;If no hard drives, exit
  120.         add     di,7fh                  ;Convert drive no. to drive id no.
  121.         inc     ch                      ;CH is now tracks + 1
  122.         jnb     pk1
  123.         add     cl,40h                  ;CL is sectors
  124. pk1:    mov     ax,0c01h                ;seek to cylinder
  125.         mov     dx,si                   ;DX is drive ID
  126.         int     13h                     ;this does the seek
  127.         inc     si                      ;bump drive count
  128.         cmp     si,di                   ;Was it the last? No? Then
  129.         jbe     pk0                     ;loop until all drives are parked
  130. pkdone:
  131. if tinkle
  132. EXTRN TESSBEEP:NEAR
  133.  
  134.         call    TESSBEEP
  135. endif
  136.         ret
  137. parkit  endp
  138.  
  139.  
  140. ;
  141. ; TesSeRact Entry Points
  142. ;
  143. ;
  144. PUBLIC  TSRUSERPROC, TSRTIMERPROC, TSRBACKCHECK, TSRMAIN, TSRBACKPROC
  145. PUBLIC  TSRCLEANUP
  146.  
  147. ;
  148. ; TSUSERPROC is a NULL procedure.  We don't service it in this program.
  149. ;
  150. ;
  151. TSRUSERPROC:                             ;Return, does nothing
  152.         ret
  153.  
  154. int13ptr        dw    0                  ;Saved location of INT 13 flag
  155.                                          ;  from TesSeRact data area
  156. do_park         db    0                  ;Flag set to 1 when wish to park
  157.  
  158. TSRminutes      db   " "                 ;Holds minutes between parks in ASCII
  159.  
  160. park_msg label near                      ;Message to display when popped up
  161.                                          ; AND at DOS prompt
  162.         db      13,10,10
  163.         db      'TSRPark has manually parked the hard disk(s)',13,10
  164.         db      'as requested.  Will automatically repark in ',13,10
  165.         db      '  minute(s) after next disk access.         ',13
  166. msg_len dw      $ - park_msg
  167.  
  168. reset_it   proc near
  169.         mov     do_park,0                ;Say not to park
  170.         mov     bx,[int13ptr]            ;Get INT13 flag
  171.         mov     byte ptr [bx],0          ;and turn off because
  172.                                          ;parking isn't using.
  173.         mov     ax,[ticks2wait]          ;Use our timer to
  174.         mov     [tick_count],ax          ;restart wait.
  175.  
  176.         ret
  177. reset_it   endp
  178.  
  179. TSRBACKCHECK proc near
  180.         assume cs:_TEXT, ds:_TEXT
  181.  
  182.         mov     al,do_park               ;Put flag in ax
  183.         xor     ah,ah                    ;if non-zero, call TSRBACKPROC
  184.         ret
  185. TSRBACKCHECK endp
  186.  
  187. TSRBACKPROC proc near
  188.         assume cs:_TEXT, ds:_TEXT
  189.  
  190.         call    parkit                   ;Attempt to park it
  191.         call    reset_it                 ;and reset everything
  192.  
  193.         ret
  194. TSRBACKPROC endp
  195.  
  196. TSRMAIN     proc near
  197.         assume cs:_TEXT, ds:_TEXT
  198.                                          ;On hotkey
  199.         call parkit                      ;P